﻿@{
    ViewData["Title"] = "包含增删查改的Table页面";
    Layout = "~/Views/Shared/_LayuiTableEdit.cshtml";
}
<form id="searchForm" onsubmit="return false;">
    <div class="layui-input-inline">
        <input class="layui-input search_input" placeholder="请输入关键字" name="searchValue" autocomplete="off">
    </div>
    <div class="layui-input-inline">
        <a class="layui-btn layui-btn-normal" onclick="tableReload()">搜索</a>
    </div>
    <div class="layui-inline">
        <button type="reset" class="layui-btn layui-btn-danger">重置</button>
    </div>
</form>
<script type="text/html" id="tableBar">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script type="text/html" id="toolbar">
    <button class="layui-btn " onclick="add()">新增</button>
</script>
<table id="mainTable" lay-filter="demo"></table>
<script>
    addLayuiUseEvent(function () {
        tableRender({
            where: getQueryWhere()
            , page: true
            , toolbar: '#toolbar'
            , url: '@ViewBag.ListUrl'
            , cols: [[
                { type: 'numbers', title: '序号' }
                , { field: 'ConsumeRemark', width: 200, align: 'center', title: '帐目说明' }
                , { field: 'TypeName', width: 90, align: 'center', title: '帐目类型' }
                , { field: 'ActName', width: 90, align: 'center', title: '账户' }
                , { field: 'Amount', width: 90, align: 'center', title: '发生额' }
                , { fixed: 'right', width: 150, align: 'center', title: '操作', toolbar: '#tableBar' }

            ]]
        });

        //var form = layui.form;
        ////监听操作
        //form.on('switch(IsEnableEvent)', function (obj) {
        //    var switchState = obj.elem.checked ;
        //    var id = $(obj.elem).attr("RecordId");
        //    jqJsonPost("/api/apiExamineRecord/updateEnable",
        //        { Id : id, IsEnable:switchState},
        //        function (data) {
        //            layer.msg(data.msg);
        //            if (data.code != 0) {
        //                obj.elem.checked = false;
        //                form.render();
        //            }
        //        });
        //});
    });
</script>